package com.atguigu.cloud.apis;

import com.atguigu.cloud.entities.PayDTO;
import com.atguigu.cloud.resp.ResultData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * ClassName:PayFeignApi
 * Package:com.atguigu.cloud.apis
 * Description:
 *
 * @Author:@郭先森
 * @Create:2025/6/20 - 10:55
 * @Version:v1.0
 */
//@FeignClient(value = "cloud-payment-service")//告诉openfeign去调用哪个微服务
//上面的写法：自己人内部，自己访问自己，写微服务名字OK
//下面的写法：不同家公司有外人，系统访外访问，先找网关再找服务
@FeignClient(value = "cloud-gateway") //告诉openfeign找网关
public interface PayFeignApi {

    //添加一条支付相关流水记录
    @PostMapping(value = "/pay/add")
    public ResultData addPay(@RequestBody PayDTO payDTO);

    //按照主键查询流水记录信息
    @GetMapping(value = "/pay/get/{id}")
    public ResultData getPayInfo(@PathVariable("id") Integer id);

    //openfeign天然支持负载均衡演示
    @GetMapping(value = "/pay/get/info")
    public String mylb();


   //Resilience4j CircuitBreaker 的例子
    @GetMapping(value = "/pay/circuit/{id}")
    public String myCircuit(@PathVariable("id") Integer id);


    //舱壁的例子
    @GetMapping(value = "/pay/bulkhead/{id}")
    public String myBulkhead(@PathVariable("id") Integer id);

    //=========Resilience4j ratelimit 的例子
    @GetMapping(value = "/pay/ratelimit/{id}")
    public String myRatelimit(@PathVariable("id") Integer id);

    @GetMapping(value = "/pay/micrometer/{id}")
    public String myMicrometer(@PathVariable("id") Integer id);

    //GateWay进行网关测试案例01
    @GetMapping(value = "/pay/gateway/get/{id}")
    public ResultData getById(@PathVariable("id") Integer id);

    //GateWay进行网关测试案例02
    @GetMapping(value = "/pay/gateway/info")
    public ResultData<String> getGatewayInfo();

}
